home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 05.zip
/
BS1 part 5
/
PDraw3.0.adf
/
pdraw_rex.lzh
/
PlotPolar.pdrx
< prev
next >
Wrap
Text File
|
1992-06-15
|
2KB
|
91 lines
/*
@N
This Genie will plot a polar mathematical function in terms of angle 'a'
*/
signal on error
signal on syntax
msg = PDSetup.rexx(2,0)
units = getclip(pds_units)
if msg ~= 1 then exit_msg(msg)
/* numeric digits 8 */
cr = '0a'x
pi2 = 6.282
call pdm_abortplot()
call pdm_initplot(4.25,5.5, 1, -1, 0,"polar")
call pdm_setlinecolor(,"black")
call pdm_plotline("0 5,0 -5,0 0,-4 0,4 0")
call pdm_endplot()
call pdm_updatescreen(1)
call pdm_setlinecolor(,"red")
function = getclip(pduser_pfunction)
start = getclip(pduser_pstart)
end = getclip(pduser_pstop)
npoints = getclip(pduser_pnpoints)
if units = 3 then
do
start = pdm_ConvertUnits(1, units, start)
end = pdm_ConvertUnits(1, units, end)
end
form = "a0:"start || cr"an:360"cr"numpoints:"npoints || cr"function:"function
form = pdm_getform("Enter function of angle 'a'", 30, form)
if form = "" then do
call pdm_deleteobj("polar")
exit_msg()
end
parse var form start '0a'x end '0a'x numpoints '0a'x function
if ~(datatype(start, n) & datatype(end, n) & datatype(numpoints, n)) then
exit_msg("Invalid Entry")
if units = 3 then
do
start = pdm_ConvertUnits(units, 1, start)
end = pdm_ConvertUnits(units, 1, end)
end
call setclip(pduser_pfunction, function)
call setclip(pduser_pstart, start)
call setclip(pduser_pstop, end)
call setclip(pduser_pnpoints, npoints)
start = start / 360 * pi2
end = end / 360 * pi2
inc = (end - start) / numpoints
do a = start to end by inc
interpret "r = "function
x = r * cos(a)
y = r * sin(a)
if y < -6 then y = -6
if y > 6 then y = 6
if x < -6 then x = -6
if x > 6 then x = 6
call pdm_plotsmooth(x" "y)
end
call pdm_endplot()
exit_msg()
exit_msg: procedure expose units
do
parse arg message
if message ~= '' then call pdm_Inform(1,message,)
call pdm_SetUnits(units)
call pdm_AutoUpdate(1)
exit
end
error:
syntax:
exit_msg("Function failed due to error: "errortext(rc))